package com.cy.store.service.impl;

import com.cy.store.entity.Product;
import com.cy.store.mapper.ProductMapper;
import com.cy.store.service.IProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class ProductServiceImpl implements IProductService {
    @Autowired
    private ProductMapper productMapper;
    @Override
    public List<Product> findHot() {
        List<Product> products = productMapper.findFour();
        for (Product product : products) {
            product.setCategoryId(null);
            product.setCreatedTime(null);
            product.setItemType(null);
            product.setNum(null);
            product.setPriority(null);
            product.setStatus(null);
            product.setModifiedTime(null);
            product.setModifiedUser(null);
            product.setCreatedUser(null);
            product.setSellPoint(null);
            product.setCategoryId(null);
        }
        return products;
    }

    @Override
    public Product findById(Integer id) {
        Product product = productMapper.findById(id);
        return product;
    }
}
